{% extends "base.html" %}
{% import 'bootstrap/wtf.html' as wtf %}

{% block title %}Blog - Write Article{% endblock%}
{% block styles %}
{{super()}}
<link rel="stylesheet" href="{{ url_for('static',filename='editormd/css/editormd.css') }}"/>
{% endblock %}

{% block page_common_content %}

<div class="main-content-section">
    <div class="row">
        {% include 'admin/_sidebar.html' %}
        <div class="col-lg-10">
            <div class="page-header page-title-top">
                <h1>Write Articles</h1>
            </div>
            <div class="col-md-12">
                <form method="POST" action=
                {% if "write" in request.url  %}
                    "{{ url_for('admin.write_article') }}"
                {% else %}
                    "{{ url_for('admin.edit_article', id=request.path.split('/')[-1]) }}"
                {% endif %}
                >
                    {{ form.hidden_tag() }}
                    <div class="form-group">
                        {{ form.title.label }}
                        {% if form.title.errors %}
                            {% for e in form.tags.errors %}
                                <div class="alert alert-warning alert-dismissible" role="alert">
                                  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                  <strong>title</strong>:{{ e }}
                                </div>
                            {% endfor %}
                        {% endif %}
                        {{ form.title(class_='form-control') }}
                    </div>

                    <div class="col-md-6 categroy">
                        <div class="form-group">
                            {{ form.category_id.label }}
                            {% if form.category_id.errors %}
                                {% for e in form.category_id.errors %}
                                    <div class="alert alert-warning alert-dismissible" role="alert">
                                      <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                      <strong>categoies</strong>: {{ e }}
                                    </div>
                                {% endfor %}
                            {% endif %}
                            {{ form.category_id(class_='form-control') }}
                        </div>
                    </div>
                    <div class="col-md-6 tag">
                        <div class="form-group">
                            {{ form.tags.label }}
                            {% if form.tags.errors %}
                                {% for e in form.tags.errors %}
                                    <div class="alert alert-warning alert-dismissible" role="alert">
                                      <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                      <strong>tags</strong>:{{ e }}
                                    </div>
                                {% endfor %}
                            {% endif %}
                            {{ form.tags(class_='form-control') }}
                        </div>
                    </div>

                    <div class="form-group">
                        {{ form.content.label }}
                        {% if form.content.errors %}
                            {% for e in form.content.errors %}
                                <div class="alert alert-warning alert-dismissible" role="alert">
                                  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                  <strong>content</strong>:{{ e }}
                                </div>
                            {% endfor %}
                        {% endif %}
                        <div id="test-editormd" class="form-control">
                            {{ form.content(style="display:none;") }}
                        </div>
                    </div>
                    <input class="btn btn-primary" type="submit" value="Submit">
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %}

{% block scripts %}
{{super()}}
<script src="{{ url_for('static',filename='editormd/editormd.min.js') }}"></script>
<script type="text/javascript">
    var testEditor;

    $(function () {
        testEditor = editormd("test-editormd", {
            width: "100%",
            height: 640,
            tex: true,
            syncScrolling: "single",
            path: "{{ url_for('static',filename='editormd/lib/') }}"
        });
    });
</script>
{% endblock %}